﻿<body>

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 分类管理 <span class="c-gray en">&gt;</span> 分类管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>



<div class="page-container">
	<div class="text-c">
		{if isset($cat)}
			<form class="Huiform" method="post" action="{{:url('/admin/cat/'.$cat.id)}}">  
			<input type="hidden" name="_method" value="PUT">
		{else/}
		<form class="Huiform" method="post" action="{{:url('/admin/cat')}}">
		{/if}
			{{:token()}}
	<input type="text" placeholder="分类名称" name="cat_name" value="{{$cat?$cat.cat_name:''}}" class="input-text" style="width:120px">
	<input type="text" placeholder="分类描述" name="cat_desc" value="{{$cat?$cat.cat_desc:''}}" class="input-text" style="width:240px">
	<input type="submit" class ="btn btn-success" value="{{$cat?'更新分类':'添加分类'}}" >
		</form>
	</div>


	{if(isset($nullInfo))}
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l">
	<a href="javascript:;"class=" col-offset-8 btn btn-danger radius"> {{$nullInfo}}</a></span> <span class="r">共有数据：<strong>{{$catCount}}</strong> 条</span> </div>

	{else/}

	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-sort">
			<thead>
				<tr class="text-c">
					<th width="25"><input type="checkbox" name="" value=""></th>
					<th width="70">ID</th>
					<th width="120">分类名称</th>
					<th>分类描述</th>
					<th width="100">操作</th>
				</tr>
			</thead>
			<tbody>
			{volist name="cats" id="vo"}
				<tr class="text-c">
					<td><input name="" type="checkbox" value=""></td>
					<td>{{$i}}</td>
					<td class="text-l">{{$vo.cat_name}}</td>
					<td class="text-l">{{$vo.cat_desc}}</td>
					<td class="f-14 product-brand-manage">
	<a style="text-decoration:none"  href="{{:url('/admin/cat/'.$vo.id.'/edit')}}" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> 
	<a style="text-decoration:none" class="ml-5" onclick="delCat({{$vo.id}})" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
				</tr>
				{/volist}
			</tbody>
		</table>
	</div>
{/if}
</div>
</body>
</html>
<script>

function delCat(id){

	layer.confirm('你确定要删除吗',function(){
		$.ajax({
			type:"DELETE",
			dataTyep:"json",
			url:"/admin/cat/"+id,
			success:function(data){
				if(data.status=='success'){
				
					layer.msg(data.info,{icon:1,time:1000},function(){
						location.href="/admin/cat";	
							
					})
				}else{
					layer.msg(data.info,{icon:2,time:1000},function(){
						        location.href="/admin/cat";     
					})
				}	
			
			
			}

		});	
				
	});


}


</script>
